# -*- mode: python ; coding: utf-8 -*-

import sys
import os

# 获取当前目录
current_dir = os.path.dirname(os.path.abspath(__file__))

# PyInstaller打包配置
block_cipher = None

a = Analysis(
    ['main.py'],
    pathex=[current_dir],
    binaries=[],
    datas=[],
    hiddenimports=[],
    hookspath=[],
    hooksconfig={},
    runtime_hooks=[],
    excludes=[],
    win_no_prefer_redirects=False,
    win_private_assemblies=False,
    cipher=block_cipher,
    noarchive=False,
)

# 收集PySide6的额外文件
from PyInstaller.utils.hooks import collect_all

datas = []
binaries = []
hiddenimports = []

# 收集PySide6相关文件
for pkg in ['PySide6']:
    pkg_datas, pkg_binaries, pkg_hiddenimports = collect_all(pkg)
    datas.extend(pkg_datas)
    binaries.extend(pkg_binaries)
    hiddenimports.extend(pkg_hiddenimports)

# 更新Analysis对象
a.datas.extend(datas)
a.binaries.extend(binaries)
a.hiddenimports.extend(hiddenimports)

pyz = PYZ(a.pure, a.zipped_data, cipher=block_cipher)

exe = EXE(
    pyz,
    a.scripts,
    a.binaries,
    a.zipfiles,
    a.datas,
    [],
    name='PyHashCalculator',
    debug=False,
    bootloader_ignore_signals=False,
    strip=False,
    upx=True,
    upx_exclude=[],
    runtime_tmpdir=None,
    console=False,  # 不显示控制台窗口
    disable_windowed_traceback=False,
    argv_emulation=False,
    target_arch=None,
    codesign_identity=None,
    entitlements_file=None,
    icon='md5.ico',  # Windows图标文件
)

# macOS应用包配置（适用于macOS系统）
if sys.platform == 'darwin':
    app = BUNDLE(
        exe,
        name='PyHashCalculator.app',
        icon='md5.icns',  # macOS图标文件
        bundle_identifier='com.pyhashcalculator.app',
        version='1.0.0',
        info_plist={
            'CFBundleDisplayName': 'PyHashCalculator',
            'CFBundleShortVersionString': '1.0.0',
            'CFBundleVersion': '1.0.0',
            'NSHighResolutionCapable': True,
            'NSRequiresAquaSystemAppearance': False,
        },
    )